#!/usr/bin/env bash

unset rvm_default_flag

source "$rvm_scripts_path/base"

[[ -n "${MY_RUBY_HOME:-}" ]] || __rvm_become default
[[ -n "${MY_RUBY_HOME:-}" ]] || {
  rvm_error "No ruby used, try 'rvm use ruby' or 'rvm ruby do rvm wrapper $*'"
  exit 3
}

case "${1:-}" in
  (show|regenerate)
    run_gem_wrappers "$@"
    ;;
  (help)
    shift
    rvm_help wrapper "$@"
    ;;
  (*)
    if
      [[ -x "$1" ]]
    then
      run_gem_wrappers "$@"
    else
      rvm_help wrapper "$@"
      exit 1
    fi
    ;;
esac
